package com.yq.design.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @ClassName InfoIterator
 * @Description InfoIterator系实现iterator，重写遍历系计系的数组，
 * @Author yaoqiang
 * @Date 2021/8/24 11:38
 * @Version 1.0
 */
public class InfoIterator implements Iterator {
    List<Department> departmentList;
    int index=-1;

    @Override
    public boolean hasNext() {
        if (index>=departmentList.size()-1){
            return false;
        }else {
            index+=1;
            return true;
        }
    }

    @Override
    public Object next() {
        return  departmentList.get(index);
    }

    public InfoIterator(List<Department> departmentList) {
        this.departmentList = departmentList;
    }

}
